load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("@aspect_rules_js//js:defs.bzl", "js_library", "js_run_binary")

js_run_binary(
    name = "build",
    outs = [
        # bazel output files names in the output tree are prefixed with `_` so
        # we can refer to both the source files & output files by label in the
        # write_source_files target below.
        "_expression.json",
        "_inline-styles.json",
        "_inline-template.json",
        "_template.json",
        "_template-blocks.json",
        "_template-tag.json",
        "_let-declaration.json",
        "_host-object-literal.json",
    ],
    tool = "//vscode-ng-language-service/syntaxes/src:build",
)

write_source_files(
    name = "syntaxes",
    files = {
        "expression.json": "_expression.json",
        "inline-styles.json": "_inline-styles.json",
        "inline-template.json": "_inline-template.json",
        "template.json": "_template.json",
        "template-blocks.json": "_template-blocks.json",
        "template-tag.json": "_template-tag.json",
        "let-declaration.json": "_let-declaration.json",
        "host-object-literal.json": "_host-object-literal.json",
    },
)

js_library(
    name = "json",
    srcs = glob(
        include = ["*.json"],
        exclude = ["tsconfig.json"],
    ),
    visibility = [
        "//vscode-ng-language-service:__pkg__",
        "//vscode-ng-language-service/syntaxes:__subpackages__",
    ],
)
